package com.example.publisher.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FanoutConfig {

    public static final String FANOUT_QUEUE_NAME = "fanout_queue_name";
    public static final String FANOUT_QUEUE_NAME2 = "fanout_queue_name2";
    public static final String FANOUT_EXCHANGE_NAME = "fanout_exchange_name";

    @Bean
    Queue createFanoutQueue(){
        return new Queue(FANOUT_QUEUE_NAME,true,false,false);
    }
    @Bean
    Queue createFanoutQueue2(){
        return new Queue(FANOUT_QUEUE_NAME2,true,false,false);
    }
    @Bean
    FanoutExchange fanoutExchange(){
        return new FanoutExchange(FANOUT_EXCHANGE_NAME,true,false);
    }

    @Bean
    Binding fanoutBinding1(){
        return BindingBuilder.bind(createFanoutQueue()).to(fanoutExchange());//no with  cause  broadcast
    }
    @Bean
    Binding fanoutBinding2(){
        return BindingBuilder.bind(createFanoutQueue2()).to(fanoutExchange());//no with  cause  broadcast
    }

}
